home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
et
/
src
/
setup.c
< prev
next >
Wrap
Text File
|
1993-07-08
|
13KB
|
554 lines
#include "et.h"
int set_max()/*et*/
{
int i, i_b, z_max;
i = i_b = 0;
z_max = (G_pm.i.dist - G_pm.i.pers) * GETA_ET;
do {
if (z_max < G_mv[i].z) {
z_max = G_mv[i].z;
i_b = i;
}
} while (G_mv[i++].key != EOK);
return(i_b);
}
int set_min()/*et*/
{
int i, i_b, z_min;
i = i_b = 0;
z_min = (G_pm.i.dist - G_pm.i.pers) * GETA_ET;
do {
if (z_min > G_mv[i].z) {
z_min = G_mv[i].z;
i_b = i;
}
} while (G_mv[i++].key != EOK);
return(i_b);
}
void set_ww(int menu_i)/*et*/
{
int cut, r_b, mm, key_i, key_b, max_i, min_i, max_b, min_b, r_d, z_d;;
disp_menu(menu_i, P_v[v_VIEW_0], 5, 0);
set_bit(G_f, f_RR);
save_key(-1);
r_b = G_pm.i.r;
key_i = 0;
do {
G_mv[key_i].r = r_b;
} while (G_mv[key_i++].key != EOK);
do {
max_i = set_max();
key_b = G_mv[max_i].key;
G_mv[max_i].key = EOK;
mm = (max_i) ? 7 : 0;
key_i = 0;
go_bar(&key_i, mm, 0);
G_pm.i.r = G_mv[max_i].r;
draw_pm(menu_i, H_WHT);
if (!mm)
draw_edge(P_SET, AFT);
copy_window(P_i[i_WIN_VRAM], P_v[v_VRAM], 0x14, PEEK);
exchange_page();
copy_window(P_i[i_WIN_VRAM], P_v[v_VRAM], 0x14, POKE);
exchange_page();
change(mn_WW);
max_b = G_pm.i.r;
G_mv[max_i].key = key_b;
min_i = set_min();
key_b = G_mv[min_i].key;
G_mv[min_i].key = EOK;
mm = (min_i) ? 7 : 0;
key_i = 0;
go_bar(&key_i, mm, 0);
G_pm.i.r = G_mv[min_i].r;
draw_pm(menu_i, H_WHT);
if (!mm)
draw_edge(P_SET, AFT);
copy_window(P_i[i_WIN_VRAM], P_v[v_VRAM], 0x14, PEEK);
exchange_page();
copy_window(P_i[i_WIN_VRAM], P_v[v_VRAM], 0x14, POKE);
exchange_page();
change(mn_WW);
min_b = G_pm.i.r;
G_mv[min_i].key = key_b;
G_mv[max_i].r = max_b;
G_mv[min_i].r = min_b;
if (max_i != min_i) {
r_d = G_mv[max_i].r - G_mv[min_i].r;
z_d = G_mv[max_i].z - G_mv[min_i].z;
cul_r(max_i, min_i, r_d, z_d);
}
key_i = 0;
cut = go_bar(&key_i, 0, 0);
} while (cut == _ESC);
mm = 4;
if (!cut)
draw_edge(P_SET, AFT);
else {
while (cut) {
if (mm == 4)
draw_edge(P_RES, AFT);
cut = go_bar(&key_i, mm, 0);
draw_edge(P_SET, AFT);
mm = (mm == 4) ? 2 : 4;
}
}
G_pm.i.r = min_b;
disp_menu(menu_i, P_v[v_VIEW_0], 6, 0);
}
void set_et_rr_col(int *col_p, int *col2_p, int *line_m_p, int mm, int ii)/*et*/
{
int i;
if (!test_bit(G_f, f_TT|f_EE|f_GPH)) {
if (test_bit(G_f, f_AA))
*col_p = (ii == ENT) ? H_RED : H_WHT;
else if (test_bit(G_f, f_TROFF))
*col_p = H_MZN;
else
*col_p = H_RED;
*line_m_p = (test_bit(G_f, f_AA) || ii == ENT) ? P_SET : P_NEG;
} else if (test_bit(G_f, f_SV) && !test_bit(G_f, f_GPH)) {
if (test_bit(G_f, f_TT))
if (test_bit(G_f, f_EE)) {
*col_p = H_RED;
*col2_p = H_SYN;
*line_m_p = P_SET;
} else {
*col_p = H_SYN;
*col2_p = 0;
*line_m_p = P_SET;
}
else {
i = test_bit(G_f, f_AA|f_NN);
*col2_p = 0;
switch(i) {
case 0:
*col_p = H_RED;
*col2_p = H_GRN;
*line_m_p = P_SET;
break;
case f_AA:
*col_p = H_RED;
*col2_p = H_WHT;
*line_m_p = P_SET;
break;
case f_NN:
*col_p = L_GRN;
*line_m_p = P_RES;
break;
}
}
} else if (test_bit(G_f, f_GPH)) {
if (!test_bit(G_f, f_EE)) {
*col_p = (mm == _LT) ? H_BLU : H_RED;
*line_m_p = (test_bit(G_f, f_AA) || ii == ENT) ? P_SET : P_NEG;
} else
if (test_bit(G_f, f_TT)) {
if (test_bit(G_f, f_EE)) {
*col_p = (mm == _LT) ? L_BLU : L_RED;
*col2_p = (mm == _LT) ? H_BLU : H_RED;
*line_m_p = P_SET;
} else {
*col_p = (mm == _LT) ? H_BLU : H_RED;
*col2_p = 0;
*line_m_p = P_SET;
}
} else {
i = test_bit(G_f, (f_AA|f_NN));
*col2_p = 0;
switch(i) {
case 0:
*col_p = (mm == _LT) ? L_BLU : L_RED;
*col2_p = (mm == _LT) ? H_BLU : H_RED;
*line_m_p = P_SET;
break;
case f_AA:
*col_p = (mm == _LT) ? L_BLU : L_RED;
*col2_p = (mm == _LT) ? H_BLU : H_RED;
*line_m_p = P_SET;
break;
case f_NN:
*col_p = H_BLK;
*line_m_p = P_RES;
break;
}
}
} else
if (test_bit(G_f, f_TT)) {
if (test_bit(G_f, f_EE)) {
*col_p = H_RED;
*col2_p = H_SYN;
*line_m_p = P_SET;
} else {
*col_p = H_SYN;
*col2_p = 0;
*line_m_p = P_SET;
}
} else {
i = test_bit(G_f, (f_AA|f_NN));
*col2_p = 0;
switch(i) {
case 0:
*col_p = H_RED;
*col2_p = H_GRN;
*line_m_p = P_SET;
break;
case f_AA:
*col_p = H_RED;
*col2_p = H_WHT;
*line_m_p = P_SET;
break;
case f_NN:
*col_p = L_GRN;
*line_m_p = P_RES;
break;
}
}
}
void cls_view(int *pq_p)/*et*/
{
int i;
VRAM *vram;
i = (pq_p == P_i[i_WIN_VRAM]) ? VRAM_SIZE : VIEW_SIZE;
vram = P_v[v_VRAM];
while (i--)
*vram++ = 0;
copy_window(pq_p, P_v[v_VRAM], 0x14, POKE);
}
void set_icn_pq(int pq_a[], int name_i, int zl)/*et*/
{
int pi, qi;
pi = name_i % 8;
qi = name_i / 8;
pq_a[0] = P_i[i_WIN_VIEW][0] + P_i[i_SIZE_ICN][2] * 8 * pi + zl;
pq_a[1] = P_i[i_WIN_VIEW][1] + P_i[i_SIZE_ICN][3] * qi + zl;
pq_a[2] = pq_a[0] + P_i[i_SIZE_ICN][2] * 8 - 1 - zl;
pq_a[3] = pq_a[1] + P_i[i_SIZE_ICN][3] - 1 - zl;
}
void set_font_pq(int pq_a[], int menu_i)/*et*/
{
pq_a[0] = G_mn[menu_i].p+80+120-8+21;
pq_a[1] = G_mn[menu_i].q-1;
pq_a[2] = G_mn[menu_i].p+98+120-8+21;
pq_a[3] = G_mn[menu_i].q+17;
}
void set_var_pq(int menu_i, int pq_a[])/*et*/
{
if (menu_i == mn_FF) {
pq_a[0] = 580;
pq_a[1] = G_mn[menu_i].q;
pq_a[2] = pq_a[0]+8*4;
pq_a[3] = pq_a[1]+15; /* 16 以上 は NG (^^; */
} else {
pq_a[0] = G_mn[menu_i].p+9*8+4;
pq_a[1] = G_mn[menu_i].q;
pq_a[2] = pq_a[0]+6*8;
pq_a[3] = pq_a[1]+16;
}
}
void set_name_pq(int menu_i, int pq_a[])/*et*/
{
pq_a[0] = G_mn[menu_i].p+(G_mn[menu_i].len+1)*8-4;
pq_a[1] = G_mn[menu_i].q-1;
pq_a[2] = pq_a[0]+(strlen(G_mn[menu_i].s)-G_mn[menu_i].len)*8-3;
pq_a[3] = pq_a[1]+17;
}
int read_key(void)/*et*/
{
int i, key;
static int add, shift;
asm volatile ("
movb $0x09,%%ah
movb $0x01,%%al
int $0x90
cmpb $0xff,%%dh
jne 0f
movl $%0,%%eax
movl $0,(%%eax)
jmp 1f
.align 4
0:
movsbl %%bh,%%ecx
movl $%0,%%eax
movl %%ecx,(%%eax)
movsbl %%bl,%%ecx
movl $%1,%%eax
movl %%ecx,(%%eax)
1:
"
:
: "g"(add),"g"(shift)
: "bx"
);
/*
regs.h.ah = 0x09;
regs.h.al = 0x01;
intreal(0x90, ®s, ®s, &segs);
if (regs.h.dh == 0xff)
add = 0;
else {
add = regs.h.bh;
shift = regs.h.bl;
}
*/
if (!add || (i = instring(add, P_c[c_ADD_KEY], sizeof(char))) == 0)
return(0);
key = P_c[c_KEY_0][i-1];
if (test_bit(shift, 0x14) == 0x14)
key += _SHIFT_CTRL-_KEY;
else if (test_bit(shift, 0x04))
key += _SHIFT-_KEY;
else if (test_bit(shift, 0x10))
key += _CTRL-_KEY;
switch(key) {
case S_C_LT:
if (G_nb.mouse)
G_nb.mouse--;
break;
case S_C_RT:
if (G_nb.mouse < MAX_MOUSE)
G_nb.mouse++;
break;
default:
break;
}
if (!test_bit(G_f, f_DEMO|f_MAKE|f_REPLAY) && !find_key(key))
key = 0;
return(key);
}
int chk_trace_mode(int menu_i)/*et*/
{
if (test_bit(G_f, f_AA))
return(menu_i);
else if (test_bit(G_f, f_NN))
return(menu_i+1);
else
return(menu_i+2);
}
int set_nb_menu()/*et*/
{
int key_i, menu_i;
key_i = nb_key(G_mv);
if (!key_i)
menu_i = chk_trace_mode(mn_MN_DEL_AA);
else if (key_i >= MAX_KEY) {
menu_i = chk_trace_mode(mn_MN_AREA_AA);
if (!test_bit(G_f, f_AREA))
set_bit(G_f, f_AREA);
} else {
menu_i = chk_trace_mode(mn_MN_AA);
if (test_bit(G_f, f_AREA))
res_bit(G_f, f_AREA);
}
return(menu_i);
}
void set_replay(int n)/*et*/
{
int i, j;
FILE *File, *Temp;
char cp[1];
File = fopen(P_c[c_FILE_REPLAY], "rb");
fseek(File, 0L, 2);
i = ftell(File);
j = i - n;
fseek(File, -j, 2);
Temp = et_fopen(P_c[c_FILE_ET_TEMP], "wb", NULL);
G_nb.drive = *P_c[c_FILE_ET_TEMP];
copy_file(Temp, File, j);
fclose(Temp);
fclose(File);
G_nb.replay = 0; /* P_c[c_FILE_ET_TEMP] の先頭に */
}
void init_et(void)/*et*/
{
int i, j;
DIR Dir[1];
init_pm();
init_key(0);
_set_break_off();
G_nb.page = 0;
display_page(G_nb.page);
G_vi.xo = P_i[i_SIZE_VIEW][2]+8;
G_vi.yo = P_i[i_SIZE_VIEW][3]+8;
G_vi.x = P_i[i_SIZE_VIEW][2];
G_vi.y = P_i[i_SIZE_VIEW][3];
G_nb.edge = G_nb.edge_b = nb_EDGE;
G_bf.dir = (DIR*)0x64000;
G_bf.pna = (DIR*)0x76000;
G_pn.pna = (char*)G_bf.pna;
Dir->next = NULL;
poke_dir(Dir, G_bf.dir);
Dir->dir = NULL;
poke_dir(Dir, G_bf.pna);
G_nb.pna_drive = G_nb.current;
for (i = 0; i < 30; i++)
P_i[i_PNA_N][i] = -1;
res_bit(G_f, f_AA|f_NN);
OUTPB(0xfda0, 4);
}
int malloc_et()/*et*/
{
int i, max_edge;
max_edge = 100;
while (1) {
G_bf.edge_buf = (char *)malloc(sizeof(EDGE) * max_edge);
G_et = (ET *)malloc(sizeof(ET) * max_edge);
G_edge = (EDGE *)malloc(sizeof(EDGE) * max_edge);
G_bf.edge = (EDGE *)malloc(sizeof(EDGE) * max_edge);
G_bf.et_buf = (char*)malloc(sizeof(EDGE) * max_edge*2);
i = G_et && G_edge && G_bf.edge && G_bf.et_buf && G_bf.edge_buf;
if (G_bf.edge_buf)
free(G_bf.edge_buf);
if (G_bf.et_buf)
free(G_bf.et_buf);
if (G_et)
free(G_et);
if (G_edge)
free(G_edge);
if (G_bf.edge)
free(G_bf.edge);
if (!i)
break;
max_edge += 100;
}
max_edge -= 100;
if (max_edge) {
G_et = (ET *)malloc((unsigned)sizeof(ET) * max_edge);
G_edge = (EDGE *)malloc((unsigned)sizeof(EDGE) * max_edge);
G_bf.edge = (EDGE *)malloc((unsigned)sizeof(EDGE) * max_edge);
G_bf.et_buf = (char*)malloc((unsigned)sizeof(EDGE) * max_edge*2);
G_bf.edge_buf = (char *)malloc((unsigned)sizeof(EDGE) * max_edge);
}
return(max_edge);
}
void free_et(void)/*et*/
{
if (G_bf.edge_buf)
free(G_bf.edge_buf);
if (G_bf.et_buf)
free(G_bf.et_buf);
if (G_et)
free(G_et);
if (G_edge)
free(G_edge);
if (G_bf.edge)
free(G_bf.edge);
}
void term_et(void)/*et*/
{
int i;
for (i = 2; i; i--, exchange_page()) {
cls_view(P_i[i_WIN_VRAM]);
if (i == 2) {
copy_window(P_i[i_WIN_VIEW], P_v[v_VIEW_0], 0x120, PEEK);
copy_window(P_i[i_WIN_VIEW], P_v[v_VIEW_1], 0x120, PEEK);
}
}
display_page(1);
OUTPB(0xfda0, 5);
init_key(1);
}
void set_ent(char *xyz_p, int j)/*et*/
{
int i;
char *c_p;
c_p = (char*)((int)G_bf.et_buf + j * sizeof(ET));
for (i = sizeof(ET); i; i--)
*c_p++ = *xyz_p++;
}
int set_key_col(void)/*et*/
{
int i;
if (test_bit(G_f, f_AA))
i = H_WHT;
else if (test_bit(G_f, f_NN))
i = H_YEL;
else
i = H_GRN;
return(i);
}
int set_csr_col(void)/*et*/
{
int i;
if (test_bit(G_f, f_AA))
i = H_WHT;
else
if (test_bit(G_f, f_TROFF))
i = H_MZN;
else
i = H_RED;
return(i);
}
void set_file_i(char *file_p, int n)/*et*/
{
int i;
for (i = 2; i; i--) {
*file_p-- = n % 10 + _00;
n /= 10;
}
}
char* shift_pna(char c_a[])/*et*/
{
int i;
char *c_p;
c_p = c_a;
do {
i = instring('\\', c_p, sizeof(char));
if (i)
c_p = &c_p[i];
} while (i);
return(c_p);
}
int set_step(int v,int key)/*et*/
{
int i;
int l;
for (l = 1; v / l && l <= 10000L; l *= 10L)
;
i = l / 10L;
switch(key) {
case _LT:
if (v < i+i/2)
i /= 10;
break;
case _RT:
if ((int)v+i > 30000)
i = 30000 - v;
break;
}
return(i);
}
void set_xyz(int xyz_a[], int rxyz_a[], int mm)/*et*/
{
int pos_x, pos_z;
pos_x = G_ps.x;
pos_z = G_ps.z;
if (mm)
pos_z -= (int)(G_pm.i.dist - G_pm.i.pers) * GETA_ET;
xyz_a[0] = rxyz_a[0] + pos_x;
xyz_a[1] = rxyz_a[1] + pos_x;
xyz_a[2] = rxyz_a[2] + G_ps.y;
xyz_a[3] = rxyz_a[3] + G_ps.y;
xyz_a[4] = rxyz_a[4] + pos_z;
xyz_a[5] = rxyz_a[5] + pos_z;
}